package views;

import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JInternalFrame;
import javax.swing.JTextField;
import javax.swing.event.InternalFrameListener;
import javax.swing.text.MaskFormatter;

@SuppressWarnings("serial")
public class RelBatidasGUI extends JInternalFrame {

	public JButton btVisualizar;
	public JFormattedTextField tfDtIni;
	public JFormattedTextField tfDtFim;

	public RelBatidasGUI() {
		super("Importar AFD", false, true, false, true);
		configComponents();
		setLayout(new FlowLayout());
		add(tfDtIni);
		add(tfDtFim);
		add(btVisualizar);
		setSize(200, 100);
	}

	private void configComponents() {
		String hoje = new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis()));		
		try {
			tfDtIni = new JFormattedTextField(new MaskFormatter("##/##/####"));
			tfDtIni.setHorizontalAlignment(JTextField.CENTER);
			tfDtIni.setText(String.valueOf(hoje));
			tfDtIni.setColumns(6);
			tfDtFim = new JFormattedTextField(new MaskFormatter("##/##/####"));
			tfDtFim.setHorizontalAlignment(JTextField.CENTER);
			tfDtFim.setText(String.valueOf(hoje));
			tfDtFim.setColumns(6);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		btVisualizar = new JButton("Visualizar");
	}

	public void setListener(ActionListener actionListener, InternalFrameListener internalFrameListener){
		btVisualizar.addActionListener(actionListener);
		this.addInternalFrameListener(internalFrameListener);
	}

}
